package com.platform.common.util;

import org.apache.commons.lang.StringUtils;

import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created with IntelliJ IDEA.
 * User: wangyanginfo
 * Date: 12-9-5
 * Time: 上午11:04
 * To change this template use File | Settings | File Templates.
 */
public class StringUtil extends StringUtils implements Cloneable {

    /**
     * 首字母转大写
     *
     * @param str 转换的字符串
     * @return 转换后字符串
     */
    public static String upperCaseFirstChar(String str) {
        if (StringUtils.isBlank(str)){
            throw new NullPointerException("String param is null");
        }
        String first = (str.substring(0, 1)).toUpperCase();
        String other = str.substring(1);
        return first + other;
    }

    /**
     *  判断一个字符串是否转换为非负整数
     * @param str 字符串
     * @return 真假
     */
    public static boolean isNumeric(String str) {
        Pattern pattern = Pattern.compile("[0-9]*");
        Matcher matcher = pattern.matcher(str);
        return matcher.matches();
    }

    /**
     * 获取UUID字符串
     * @return
     */
    public static String getUUID() {
        String uuid = UUID.randomUUID().toString().replace("-","");
        return uuid;
    }

}
